<template>
    <div>
       <el-form :model="form" label-width="100px">
            <el-row>
                <el-col :span = "12">
                    <el-form-item label="借阅人：">{{form.userName}}</el-form-item>
                </el-col>
                <el-col :span = "12">
                    <el-form-item label="借阅目的：">{{form.borrowReason}}</el-form-item>
                </el-col>
               <el-col :span="12">
                  <el-form-item label="申请日期：">{{ form.planBorrowDate }}</el-form-item>
               </el-col>
               <el-col :span="12">
                  <el-form-item label="归还日期：">{{ form.planBackDate }}</el-form-item>
               </el-col>
               <el-col :span="12">
                    <el-form-item label="状态">
                        <dict-tag :options = "borrow_status" :value ="form.status"/>
                    </el-form-item>
               </el-col>
            </el-row>
            <el-table :data="arcBorrowDetailsList" :row-class-name="rowArcBorrowDetailsIndex">
                <el-table-column label="序号" align="center" prop="index" width="50"/>
                <el-table-column label="档案号" prop="archiveCode" width="240"/>
                <el-table-column label="题名" prop="archiveTitle" width="240"/>
                <el-table-column label="密级" prop="archiveSecretLevel" width="240">
                        <template #default="scope">
                            <dict-tag :options="secret_level" :value="scope.row.archiveSecretLevel"/>
                        </template>
                    </el-table-column>
            </el-table>
         </el-form>
         
    </div>
</template>

<script setup name ="BorrowDetail">
import {  getBorrow } from "@/api/borrow/borrow";

const { proxy } = getCurrentInstance();
const { secret_level,borrow_status } = proxy.useDict('secret_level','borrow_status');
    const props = defineProps({
        borrowId:Number,
        default:0,
    })
    const form = ref({})
    const arcBorrowDetailsList  = ref([])

    function init(){
        getBorrow(props.borrowId).then(response => {
            form.value = response.data;
            arcBorrowDetailsList.value = response.data.arcBorrowDetailsList;
        }); 
    }
    /** 借阅详情序号 */
    function rowArcBorrowDetailsIndex({ row, rowIndex }) {
    row.index = rowIndex + 1;
    }
    init();
</script>